<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" media="screen" href="../../css/bootstrap.min.css">
</head>
<body>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
	<form class="form-horizontal" onsubmit="return false" id="form">
		<fieldset>
			<input type="hidden" id="id" name="id">
			<div class='form-group'>
				<label class='col-md-2 control-label'>mediaName</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='mediaName' type='text' name='mediaName' id='mediaName' data-bv-notempty='true' data-bv-notempty-message='mediaName 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>mediaPath</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='mediaPath' type='text' name='mediaPath' id='mediaPath' data-bv-notempty='true' data-bv-notempty-message='mediaPath 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>mediaType</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='mediaType' type='text' name='mediaType' id='mediaType' data-bv-notempty='true' data-bv-notempty-message='mediaType 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>updater</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='updater' type='text' name='updater' id='updater' data-bv-notempty='true' data-bv-notempty-message='updater 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>state</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='state' type='text' name='state' id='state' data-bv-notempty='true' data-bv-notempty-message='state 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>mediaNote</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='mediaNote' type='text' name='mediaNote' id='mediaNote' data-bv-notempty='true' data-bv-notempty-message='mediaNote 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>mediaRemark</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='mediaRemark' type='text' name='mediaRemark' id='mediaRemark' data-bv-notempty='true' data-bv-notempty-message='mediaRemark 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>fileSize</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='fileSize' type='text' name='fileSize' id='fileSize' data-bv-notempty='true' data-bv-notempty-message='fileSize 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>mediaClassification</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='mediaClassification' type='text' name='mediaClassification' id='mediaClassification' data-bv-notempty='true' data-bv-notempty-message='mediaClassification 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>mediaTime</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='mediaTime' type='text' name='mediaTime' id='mediaTime' data-bv-notempty='true' data-bv-notempty-message='mediaTime 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>creater</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='creater' type='text' name='creater' id='creater' data-bv-notempty='true' data-bv-notempty-message='creater 不能为空'>
				</div>
			</div>



			<div class="form-actions">
				<div class="row" align="center">
					<div class="col-md-12">
					    <button class="btn btn-primary" onclick="location.href='tswMediaLibraryList.html'">返回</button>
						<button class="btn btn-primary" type="submit" onclick="update()">
							<i class="fa fa-save"></i> 保存
						</button>
					</div>
				</div>
			</div>

		</fieldset>
	</form>
</div>
	<script type="text/javascript" src="../../js/libs/jquery-2.1.1.min.js"></script>
	<script type="text/javascript" src="../../js/jq.js"></script>
	<script type="text/javascript" src="../../js/plugin/bootstrapvalidator/bootstrapValidator.min.js"></script>
	<script type="text/javascript" src="../../js/common.js"></script>
	<script type="text/javascript" src="../../layui/layui.js"></script>
	<script type="text/javascript">
		layui.use(['layer','laydate'], function(){
		    var layer = layui.layer;
		});
		
		initData();
		
		function initData(){
			var id = getUrlParam("id");
			if(id != ""){
				$.ajax({
					type : 'get',
					url : '/tswMediaLibrarys/'+id,
					async : false,
					success : function(data) {
						$('#id').val(data.id);
						$('#mediaName').val(data.mediaName);
						$('#mediaPath').val(data.mediaPath);
						$('#mediaType').val(data.mediaType);
						$('#updater').val(data.updater);
						$('#updateTime').val(data.updateTime);
						$('#state').val(data.state);
						$('#mediaNote').val(data.mediaNote);
						$('#mediaRemark').val(data.mediaRemark);
						$('#fileSize').val(data.fileSize);
						$('#mediaClassification').val(data.mediaClassification);
						$('#mediaTime').val(data.mediaTime);
						$('#creater').val(data.creater);

					}
				});
			}
		}

		function update() {
			$('#form').bootstrapValidator();
			var bootstrapValidator = $("#form").data('bootstrapValidator');
			bootstrapValidator.validate();
		    if(!bootstrapValidator.isValid()){
			   return;
		    }
		    
		    var formdata = $("#form").serializeObject();

			$.ajax({
				type : 'put',
				url : '/tswMediaLibrarys',
				contentType: "application/json; charset=utf-8",  
				data : JSON.stringify(formdata),
				success : function(data) {
					layer.msg("修改成功", {shift: -1, time: 1000}, function(){
                        location.href = "tswMediaLibraryList.html";
                    });
				}
			});
		}
		
	</script>
</body>
</html>
